package main

import "fmt"

type SayHello interface{
	hello()
}

type Chinese struct{
	name string
}

type American struct{
	name string
}

func (c Chinese)hello(){
	fmt.Println("你好")
}

func (a American)hello(){
	fmt.Println("Hello")
}

type Stu struct{

}

//s为多态参数
func sayHello(s SayHello){
	s.hello()
}


func main(){
	//定义一个SayHello接口数组，里面存放American，Chinese结构体变量
	//多态数组，通过接口类型来收符合接口规范但不同类型的对象
	var arr [3]SayHello
	arr[0] = American{"roro"}
	arr[1] = Chinese{"Lee"}
	arr[2] = Chinese{"Hui"}

	fmt.Println(arr)

	var c Chinese = Chinese{"Lee"}
	c.hello()

	var a American
	a.hello()

	sayHello(a)
	sayHello(c)
}